<!DOCTYPE html>
<html lang="zh-CN">
<head hexo-theme='https://github.com/volantis-x/hexo-theme-volantis/tree/4.1.5'>
  <meta charset="utf-8">
  <!-- SEO相关 -->
  
    
  
  <!-- 渲染优化 -->
  <meta http-equiv='x-dns-prefetch-control' content='on' />
  <link rel='dns-prefetch' href='https://cdn.jsdelivr.net'>
  <link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>
  <meta name="renderer" content="webkit">
  <meta name="force-rendering" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <meta name="HandheldFriendly" content="True" >
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  <!-- 页面元数据 -->
  
  <title>Internet安全协议与分析Notes - Schenk - Blog</title>
  

  
    <meta name="description" content="Internet安全协议与分析期末复习">
  

  <!-- feed -->
  

  <!-- import meta -->
  

  <!-- link -->
  
    <link rel="shortcut icon" type='image/x-icon' href="https://cdn.jsdelivr.net/gh/Schenk75/Source/logos/steroids.svg">
  

  <!-- import link -->
  

  
    
<link rel="stylesheet" href="/css/first.css">

  

  
  <link rel="stylesheet" href="/css/style.css" media="print" onload="this.media='all';this.onload=null">
  <noscript><link rel="stylesheet" href="/css/style.css"></noscript>
  

  <script id="loadcss"></script>

</head>

<body>
  

<header id="l_header" class="l_header auto shadow blur floatable show" style='opacity: 0' >
  <div class='container'>
  <div id='wrapper'>
    <div class='nav-sub'>
      <p class="title"></p>
      <ul class='switcher nav-list-h m-phone' id="pjax-header-nav-list">
        <li><a id="s-comment" class="fas fa-comments fa-fw" target="_self" href='javascript:void(0)'></a></li>
        
          <li><a id="s-toc" class="s-toc fas fa-list fa-fw" target="_self" href='javascript:void(0)'></a></li>
        
      </ul>
    </div>
		<div class="nav-main">
      
        
        <a class="title flat-box" target="_self" href='/'>
          
            <img no-lazy class='logo' src='https://cdn.jsdelivr.net/gh/Schenk75/Source@latest/logos/taiga.svg'/>
          
          
          
        </a>
      

			<div class='menu navigation'>
				<ul class='nav-list-h m-pc'>
          
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/
                  
                  
                  
                    id="home"
                  >
                  <i class='fab fa-stack-overflow fa-fw'></i>主页
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/categories/
                  
                  
                  
                    id="categories"
                  >
                  <i class='fas fa-folder-open fa-fw'></i>分类
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/tags/
                  
                  
                  
                    id="tags"
                  >
                  <i class='fas fa-tags fa-fw'></i>标签
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/archives/
                  
                  
                  
                    id="archives"
                  >
                  <i class='fas fa-archive fa-fw'></i>归档
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/friends/
                  
                  
                  
                    id="friends"
                  >
                  <i class='fas fa-link fa-fw'></i>友链
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/about/
                  
                  
                  
                    id="about"
                  >
                  <i class='fas fa-info-circle fa-fw'></i>关于
                </a>
                
              </li>
            
          
          
				</ul>
			</div>

      <div class="m_search">
        <form name="searchform" class="form u-search-form">
          <i class="icon fas fa-search fa-fw"></i>
          <input type="text" class="input u-search-input" placeholder="Search..." />
        </form>
      </div>

			<ul class='switcher nav-list-h m-phone'>
				
					<li><a class="s-search fas fa-search fa-fw" target="_self" href='javascript:void(0)'></a></li>
				
				<li>
          <a class="s-menu fas fa-bars fa-fw" target="_self" href='javascript:void(0)'></a>
          <ul class="menu-phone list-v navigation white-box">
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/
                  
                  
                  
                    id="home"
                  >
                  <i class='fab fa-stack-overflow fa-fw'></i>主页
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/categories/
                  
                  
                  
                    id="categories"
                  >
                  <i class='fas fa-folder-open fa-fw'></i>分类
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/tags/
                  
                  
                  
                    id="tags"
                  >
                  <i class='fas fa-tags fa-fw'></i>标签
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/archives/
                  
                  
                  
                    id="archives"
                  >
                  <i class='fas fa-archive fa-fw'></i>归档
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/friends/
                  
                  
                  
                    id="friends"
                  >
                  <i class='fas fa-link fa-fw'></i>友链
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/about/
                  
                  
                  
                    id="about"
                  >
                  <i class='fas fa-info-circle fa-fw'></i>关于
                </a>
                
              </li>
            
          
            
          </ul>
        </li>
			</ul>
		</div>
	</div>
  </div>
</header>

  <div id="l_body">
    <div id="l_cover">
  
    
        <div id="full" class='cover-wrapper post dock' style="display: none;">
          
            <div class='cover-bg lazyload placeholder' data-bg="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/common/interstellar.jpg"></div>
          
          <div class='cover-body'>
  <div class='top'>
    
    
      <p class="title">Schenk - Blog</p>
    
    
      <p class="subtitle">SJTUer | Cuber</p>
    
  </div>
  <div class='bottom'>
    <div class='menu navigation'>
      <div class='list-h'>
        
          
            <a href="/categories/"
              
              
              id="categories">
              <i class='fas fa-folder-open fa-fw'></i><p>分类</p>
            </a>
          
            <a href="/tags/"
              
              
              id="tags">
              <i class='fas fa-tags fa-fw'></i><p>标签</p>
            </a>
          
            <a href="/archives/"
              
              
              id="archives">
              <i class='fas fa-archive fa-fw'></i><p>归档</p>
            </a>
          
            <a href="/friends/"
              
              
              id="friends">
              <i class='fas fa-link fa-fw'></i><p>友链</p>
            </a>
          
            <a href="/about/"
              
              
              id="about">
              <i class='fas fa-info-circle fa-fw'></i><p>关于</p>
            </a>
          
        
      </div>
    </div>
  </div>
</div>

          <div id="scroll-down" style="display: none;"><i class="fa fa-chevron-down scroll-down-effects"></i></div>
        </div>
    
  
  </div>

    <div id='safearea'>
      <div class='body-wrapper' id="pjax-container">
        

<div class='l_main'>
  <article class="article post white-box reveal md shadow floatable article-type-post" id="post" itemscope itemprop="blogPost">
  


  
  <div class="article-meta" id="top">
    
    
    
      <h1 class="title">
        Internet安全协议与分析Notes
      </h1>
      <div class='new-meta-box'>
        
          
            
<div class='new-meta-item author'>
  <a class='author' href="/" rel="nofollow">
    <img no-lazy src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/common/avatar.jpg">
    <p>Schenk</p>
  </a>
</div>

          
        
          
            
  <div class='new-meta-item category'>
    <a class='notlink'>
      <i class="fas fa-folder-open fa-fw" aria-hidden="true"></i>
      <a class="category-link" href="/categories/Notes/">Notes</a>
    </a>
  </div>


          
        
          
            <div class="new-meta-item date" itemprop="dateUpdated" datetime="2022-04-28T15:30:06+08:00">
  <a class='notlink'>
    <i class="fas fa-edit fa-fw" aria-hidden="true"></i>
    <p>更新于：2022年4月28日</p>
  </a>
</div>

          
        
          
            
  <div class="new-meta-item wordcount">
    <a class='notlink'>
      <i class="fas fa-keyboard fa-fw" aria-hidden="true"></i>
      <p>字数：2.2k字</p>
    </a>
  </div>
  <div class="new-meta-item readtime">
    <a class='notlink'>
      <i class="fas fa-hourglass-half fa-fw" aria-hidden="true"></i>
      <p>时长：8分钟</p>
    </a>
  </div>


          
        
          
            
  <div class="new-meta-item browse leancloud">
    <a class='notlink'>
      
      <div id="lc-pv" data-title="Internet安全协议与分析Notes" data-path="/2020/11/25/learning-notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes/">
        <i class="fas fa-eye fa-fw" aria-hidden="true"></i>
        <span id='number'><i class="fas fa-circle-notch fa-spin fa-fw" aria-hidden="true"></i></span>
        次浏览
      </div>
    </a>
  </div>


          
        
      </div>
    
  </div>


  
  <h2 id="IPSec">IPSec</h2>
<p><img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101110459619.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101110459619.png" srcset="" alt="image-20201101110459619"></p>
<h3 id="通信保护协议">通信保护协议</h3>
<h4 id="AH">AH</h4>
<ul>
<li>通信提供数据源认证、<strong>抗抵赖性</strong>、数据完整性和反重播保证，但不提供机密性保护</li>
</ul>
<p><strong>AH传输模式</strong></p>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101111305325.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101111305325.png" srcset="" alt="image-20201101111305325" style="zoom:80%;" />
<ul>
<li>源IP地址、目的IP地址是不能修改的，否则会被检测出来，因此AH在传输模式下和NAT冲突</li>
</ul>
<p><strong>AH隧道模式</strong></p>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101111704982.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101111704982.png" srcset="" alt="image-20201101111704982" style="zoom:80%;" />
<ul>
<li>AH验证的范围也是整个IP包，因此AH和NAT的冲突在隧道模式下也存在</li>
</ul>
<h4 id="ESP">ESP</h4>
<ul>
<li>为IP提供<strong>机密性</strong>、数据源认证、抗重播以及数据完整性等安全服务，但不提供抗抵赖性</li>
<li>对IP头部不进行认证，因此不会和NAT冲突</li>
</ul>
<p><strong>ESP传输模式</strong></p>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101112035985.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101112035985.png" srcset="" alt="image-20201101112035985"  />
<p><strong>ESP隧道模式</strong></p>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101112141274.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101112141274.png" srcset="" alt="image-20201101112141274" style="zoom:80%;" />
<h3 id="密钥交换管理协议IKE">密钥交换管理协议IKE</h3>
<ul>
<li>安全机制
<ul>
<li>前向安全性：一个密钥被破解不影响其他密钥的安全性</li>
<li>数据验证</li>
<li>DH交换和密钥分发</li>
</ul>
</li>
</ul>
<h4 id="阶段1">阶段1</h4>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101113424882.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101113424882.png" srcset="" alt="image-20201101113424882" style="zoom:80%;" />
<p><strong>主模式协商</strong></p>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101113221833.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101113221833.png" srcset="" alt="image-20201101113221833" style="zoom:80%;" />
<p><strong>野蛮模式协商</strong></p>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101113300883.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101113300883.png" srcset="" alt="image-20201101113300883" style="zoom:80%;" /> 
<p><strong>两种模式对比</strong></p>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101113329111.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101113329111.png" srcset="" alt="image-20201101113329111" style="zoom:80%;" />
<h4 id="阶段2">阶段2</h4>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101113446458.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101113446458.png" srcset="" alt="image-20201101113446458" style="zoom:80%;" />
<h2 id="SSL">SSL</h2>
<ul>
<li>安全机制
<ul>
<li>数据机密性：对称加密</li>
<li>身份验证机制：基于证书的数字签名</li>
<li>消息完整性：MAC算法</li>
</ul>
</li>
<li>SSL连接和会话
<ul>
<li>连接是点对点的、暂时的</li>
<li>会话是客户端和服务器之间持久的关联</li>
</ul>
</li>
</ul>
<h3 id="SSL分层结构">SSL分层结构</h3>
<ul>
<li>上层协议
<ul>
<li>SSL握手协议：协商加密套件，交换密钥，身份认证</li>
<li>SSL password变化协议：修改新的加密套件和密钥</li>
<li>SSL警告协议：当其他过程中出现错误或发送异常时，向对方报告告警信息</li>
</ul>
</li>
<li>下层协议
<ul>
<li>SSL记录协议：对上层数据分块、压缩、加密、传输</li>
</ul>
</li>
</ul>
<h4 id="SSL握手协议">SSL握手协议</h4>
<p><strong>阶段1：建立安全能力</strong></p>
<ul>
<li>协商加密套件</li>
</ul>
<p><strong>阶段2：服务器鉴别与密钥交换</strong></p>
<p><strong>阶段3：客户端鉴别与密钥交换</strong></p>
<ul>
<li>服务器和客户端分别发送自己的证书并交换密钥信息以便进行身份认证</li>
</ul>
<p><strong>阶段4：完成</strong></p>
<ul>
<li>检验双方是否获得同样的安全参数</li>
</ul>
<h4 id="SSL记录协议">SSL记录协议</h4>
<p>为每个SSL连接提供：</p>
<ul>
<li>机密性</li>
<li>完整性</li>
</ul>
<h3 id="SSL协议安全性分析">SSL协议安全性分析</h3>
<ul>
<li>鉴别机制：公开密钥机制和数字证书</li>
<li>加密机制：混合密码体制</li>
<li>完整性机制：定义了共享的、可以用来形成报文鉴别码MAC的密钥</li>
<li>抗重放攻击：序列号，用随机数标记握手</li>
</ul>
<h3 id="SSL脆弱性分析">SSL脆弱性分析</h3>
<ul>
<li>客户端假冒</li>
<li>无法提供基于UDP的应用的安全保护</li>
<li>不能对抗通信流量分析：SSL只对数据进行保护，数据包的IP头和TCP头暴露在外</li>
<li>SSL进程存储空间中的主密钥泄露</li>
</ul>
<h2 id="SET">SET</h2>
<h3 id="双重数字签名">双重数字签名</h3>
<ul>
<li>订单信息OI：客户给商家</li>
<li>支付信息PI：客户给银行</li>
</ul>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101125501014.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101125501014.png" srcset="" alt="image-20201101125501014" style="zoom:80%;" />
<h3 id="SET电子支付流程">SET电子支付流程</h3>
<ol>
<li>
<p>支付初始化：持卡人选择商品，下订单，选择银行卡</p>
<ul>
<li>初始请求：持卡人发送请求指定交易环境</li>
<li>初始应答：商家回复交易环境信息，以及证书等，并附上签名</li>
</ul>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101125955162.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101125955162.png" srcset="" alt="image-20201101125955162" style="zoom:80%;" />
</li>
<li>
<p>购物请求：</p>
<ul>
<li>持卡人检查商家初始应答发送的签名信息，确保数据完整性</li>
<li>持卡人发送PReq</li>
</ul>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101130235811.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101130235811.png" srcset="" alt="image-20201101130235811" style="zoom:80%;" />
</li>
</ol>
<p><img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101130805188.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101130805188.png" srcset="" alt="image-20201101130805188" style="zoom:150%;" /><img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101131210287.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101131210287.png" srcset="" alt="image-20201101131210287"></p>
<ol start="3">
<li>
<p>商家验证持卡人的身份和授权</p>
<ul>
<li>商家将相关信息发送给支付网关</li>
</ul>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101131339258.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101131339258.png" srcset="" alt="image-20201101131339258" style="zoom:150%;" />
</li>
<li>
<p>支付网关认证</p>
<ul>
<li>网关将信息发送给银行</li>
</ul>
<p><img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101132850316.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101132850316.png" srcset="" alt="image-20201101132850316"></p>
</li>
<li>
<p>收单银行处理</p>
<ul>
<li>
<p>确保PI和AuthReq的一致性</p>
</li>
<li>
<p>校验持卡人和商家对于订购行为的一致性</p>
</li>
<li>
<p>发送AuthRes给商家</p>
</li>
</ul>
<p><img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101133223907.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101133223907.png" srcset="" alt="image-20201101133223907"></p>
</li>
<li>
<p>支付完成</p>
<ul>
<li>通过捕获令牌(Capture Token)完成支付</li>
</ul>
</li>
<li>
<p>下单回复</p>
<p><img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101133759144.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101133759144.png" srcset="" alt="image-20201101133759144"></p>
</li>
</ol>
<h3 id="SET核心技术">SET核心技术</h3>
<ul>
<li>公开密钥加密</li>
<li>数字签名</li>
<li>数字信封：公钥算法加密对称密钥</li>
<li>电子安全证书</li>
</ul>
<h2 id="PGP">PGP</h2>
<ul>
<li>提供可用于电子邮件和文件存储应用的<strong>保密</strong>与<strong>鉴别</strong>服务</li>
</ul>
<h3 id="PGP数字签名与认证">PGP数字签名与认证</h3>
<p><img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101134921229.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101134921229.png" srcset="" alt="image-20201101134921229"></p>
<h3 id="PGP保密性">PGP保密性</h3>
<p><img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101135128996.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101135128996.png" srcset="" alt="image-20201101135128996"></p>
<ul>
<li>邮件的存储转发特性不适合用DH算法交换密钥</li>
<li>使用公钥算法对每个消息生成<strong>一次性</strong>会话密钥</li>
</ul>
<h3 id="PGP保密和认证结合">PGP保密和认证结合</h3>
<p><img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101135448177.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101135448177.png" srcset="" alt="image-20201101135448177"></p>
<h3 id="PGP压缩">PGP压缩</h3>
<ul>
<li>使用ZIP算法</li>
<li>先签名后压缩
<ul>
<li>只需要存储原始报文和签名</li>
<li>易于更换压缩算法</li>
</ul>
</li>
</ul>
<h3 id="PGP密钥环">PGP密钥环</h3>
<ul>
<li>每个结点都有存储密钥的结构
<ul>
<li>私钥环：存储该结点拥有的公/私钥对</li>
<li>公钥环：存储该结点拥有的其他所有用户的公钥</li>
</ul>
</li>
</ul>
<h3 id="PGP信任网">PGP信任网</h3>
<ul>
<li>PGP中没有认证机构，而是由用户互相对对方的公钥进行数字签名</li>
<li>确认是否信任
<ul>
<li>通过自己的数字签名</li>
<li>通过自己完全信任的人的数字签名</li>
<li>通过自己有限信任的多个人的数字签名</li>
</ul>
</li>
</ul>
<h2 id="Kerberos">Kerberos</h2>
<ul>
<li>采用传统加密算法(非公钥算法)</li>
</ul>
<h3 id="基本概念">基本概念</h3>
<ul>
<li>Principle：安全个体，有名字和口令</li>
<li>KDC：网络服务，提供ticket和临时会话密钥</li>
<li>Ticket：客户用来向服务器证明身份的票据
<ul>
<li>其大多数信息被服务器的密钥加密</li>
</ul>
</li>
<li>Authenticator：包含最近产生的信息的记录，需要用到会话密钥</li>
<li>Credentials：一个Ticket加上秘密的会话密钥</li>
<li>AS：Authentication Server
<ul>
<li>通过long-term key认证用户</li>
<li>授予用户ticket granting ticket和short-term key</li>
<li>认证服务</li>
</ul>
</li>
<li>TGS：Ticket Granting Server
<ul>
<li>通过ticket granting ticket和short-term key认证用户</li>
<li>发放service granting ticket给用户以访问其他服务器</li>
<li>授权和访问控制服务</li>
</ul>
</li>
</ul>
<h3 id="Kerberos工作流程">Kerberos工作流程</h3>
<h4 id="1-认证服务交换：获得票据许可票据-ticket-granting-ticket">1. 认证服务交换：获得票据许可票据(ticket granting ticket)</h4>
<p><img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101144837036.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101144837036.png" srcset="" alt="image-20201101144837036"></p>
<h4 id="2-票据许可服务交换：获得服务许可票据-service-granting-ticket">2. 票据许可服务交换：获得服务许可票据(service granting ticket)</h4>
<p><img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101145139960.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101145139960.png" srcset="" alt="image-20201101145139960"></p>
<h4 id="3-客户-服务器认证交换：获得服务image-20201101145321623">3. 客户/服务器认证交换：获得服务<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101145321623.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101145321623.png" srcset="" alt="image-20201101145321623"></h4>
<h3 id="Kerberos跨域认证">Kerberos跨域认证</h3>
<ol>
<li>获得本地TGS访问权</li>
<li>请求一张远程TGS的票据许可票据</li>
<li>向远程TGS请求其域内的服务</li>
</ol>
<img src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101145413287.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/notes/Internet%E5%AE%89%E5%85%A8%E5%8D%8F%E8%AE%AENotes//image-20201101145413287.png" srcset="" alt="image-20201101145413287" style="zoom: 50%;" />
<h3 id="Kerberos优缺点">Kerberos优缺点</h3>
<h4 id="优点">优点</h4>
<ul>
<li>密码不在网上传输，不易被窃听，难以猜测</li>
<li>单点登录机制，只用输入一次口令</li>
<li>票据被盗之后难以使用，因为需要配合认证头来使用</li>
</ul>
<h4 id="缺点">缺点</h4>
<ul>
<li>缺乏撤销机制</li>
<li>密钥管理复杂</li>
<li>跨域认证复杂</li>
<li>需要始终同步</li>
<li>需要始终在线的AS和TGS</li>
</ul>
<h2 id="BAN">BAN</h2>
<h3 id="所用符号">所用符号</h3>
<ul>
<li>
<p>A, B, S：泛指参与协议的主体</p>
</li>
<li>
<p>P, Q, R：主体变量</p>
</li>
<li>
<p>X, Y: 公式变量</p>
</li>
<li>
<p>K: 密钥变量</p>
</li>
<li>
<p>K<sub>ab</sub>, K<sub>bs</sub>, K<sub>as</sub>: 主体之间的共享密钥</p>
</li>
<li>
<p>K<sub>a</sub>, K<sub>b</sub>, K<sub>s</sub>: 主体的公钥</p>
</li>
<li>
<p>K<sub>a</sub><sup>-1</sup>, K<sub>b</sub><sup>-1</sup>, K<sub>s</sub><sup>-1</sup>: 主体的私钥</p>
</li>
<li>
<p>N<sub>a</sub>, N<sub>b</sub>, N<sub>s</sub>：主体各自生成的用于确认新鲜性的随机数Nonce</p>
</li>
<li>
<p>{X}<sub>k</sub>：用密钥k加密X的结果</p>
</li>
<li>
<p>&lt;X&gt;Y：X和Y的组合</p>
</li>
<li>
<p>P-&gt;Q:(X)：P发送消息X给Q</p>
</li>
<li>
<p>bel(P,Q)：主体P相信X</p>
</li>
<li>
<p>sees(P,X)：P接收到X</p>
</li>
<li>
<p>said(P,X)：P发送X</p>
</li>
<li>
<p>cont(P,X)：P拥有对X正确与否的判决权</p>
</li>
<li>
<p>fresh(X)：X是新鲜的</p>
</li>
<li>
<p>skey(P,K,Q)：K是P,Q的共享密钥</p>
</li>
<li>
<p>goodkey(P,K,Q)：K是P,Q共享的良好密钥</p>
</li>
<li>
<p>pubkey(P,K)：K是P的公钥</p>
</li>
<li>
<p>secret(P,X,Q)：X是P和Q的共享秘密</p>
</li>
</ul>
<h3 id="推理规则">推理规则</h3>
<h4 id="消息意义规则">消息意义规则</h4>
<p>从加密消息所使用密钥以及消息中包含的秘密来推断消息发送者的身份</p>
<ul>
<li>例如对于共享密钥：bel(P,goodkey(P,K,Q)) and sees(P,{X}<sub>k</sub>) =&gt; bel(P,said(Q,X))</li>
</ul>
<h4 id="随机数验证规则">随机数验证规则</h4>
<p>如果P相信X是新鲜的，并且P相信Q曾经发送过X，那么P相信Q相信X</p>
<ul>
<li>bel(P,fresh(X)) and bel(P,said(Q,X)) =&gt; bel(P,bel(Q,X))</li>
</ul>
<h4 id="仲裁规则">仲裁规则</h4>
<p>如果P相信Q对X是有仲裁权的，并且P相信Q相信X，那么P相信X</p>
<ul>
<li>bel(P,cont(Q,X)) and bel(P,bel(Q,X)) =&gt; bel(P,X)</li>
</ul>
<h4 id="信仰规则">信仰规则</h4>
<ul>
<li>
<p>bel(P,X) and bel(P,Y) =&gt; bel(P,(X,Y))</p>
</li>
<li>
<p>bel(P,(X,Y)) =&gt; bel(P,X) or bel(P,Y)</p>
</li>
<li>
<p>bel(P,bel(Q,(X,Y))) =&gt; bel(P,bel(Q,X)) or bel(P,bel(Q,Y))</p>
</li>
</ul>
<h4 id="接收规则">接收规则</h4>
<ul>
<li>如果P接收到一个消息，那么P也接收到这个消息的一部分
<ul>
<li>sees(P,(X,Y)) =&gt; sees(P,X)</li>
<li>sees(P,&lt;X&gt;Y) =&gt; sees(P,X)</li>
</ul>
</li>
<li>如果P收到加密消息，那么以下三种情况P可以读出消息原文
<ul>
<li>bel(P,goodkey(P,K,Q)) and sees(P,{X}<sub>K</sub>) =&gt; sees(P,X)</li>
<li>bel(P,pubkey(P,K)) and sees(P,{X}<sub>K</sub>) =&gt; sees(P,X)</li>
<li>bel(P,pubkey(Q,K)) and sees(P,{X}<sub>K</sub><sup>-1</sup>) =&gt; sees(P,X)</li>
</ul>
</li>
</ul>
<h4 id="新鲜规则">新鲜规则</h4>
<p>如果消息的一部分是新鲜的，则整个消息是新鲜的</p>
<ul>
<li>bel(P,fresh(X)) =&gt; bel(P,fresh(X,Y))</li>
</ul>
<h4 id="传递规则">传递规则</h4>
<p>如果P相信Q曾经发送过整个消息，那么P相信Q曾经发送过消息的部分</p>
<ul>
<li>bel(P,said(Q,(X,Y))) =&gt; bel(P,said(Q,X))</li>
</ul>

  
  
    
    <div class='footer'>
      
      
      
      
    </div>
  
  
    


  <div class='article-meta' id="bottom">
    <div class='new-meta-box'>
      
        
          <div class="new-meta-item date">
  <a class='notlink'>
    <i class="fas fa-calendar-alt fa-fw" aria-hidden="true"></i>
    <p>发布于：2020年11月25日</p>
  </a>
</div>

        
      
        
          

        
      
    </div>
  </div>


  
  

  
    <div class="prev-next">
      
        <a class='prev' href='/2020/11/25/paper-reading/paper-sgx-support-for-dynamic-memory-management-inside-an-enclave/'>
          <p class='title'><i class="fas fa-chevron-left" aria-hidden="true"></i>论文阅读-SGX Support for Dynamic Memory Management Inside an Enclave</p>
          <p class='content'>1. Introduction
SGX1 shortcomings


enclave建立时必须分配其所需的所有内存，并且难以根据工作量自适应分配enclave，需要根据最坏情况的工作量来分配内...</p>
        </a>
      
      
        <a class='next' href='/2020/11/25/learning-notes/SGX-Developer-Guide-Notes/'>
          <p class='title'>SGX Developer Guide - Reading Notes<i class="fas fa-chevron-right" aria-hidden="true"></i></p>
          <p class='content'>专业名词


ECall：“Enclave Call”一个调用enclave内部接口函数的操作


OCall：“Out call”从enclave内部向外部的应用发起调用的操作


Trust...</p>
        </a>
      
    </div>
  
</article>


  

  






</div>
<aside class='l_side'>
  
  
    
    



  <section class="widget toc-wrapper shadow floatable desktop mobile" id="toc-div" >
    
  <header>
    
      <i class="fas fa-list fa-fw" aria-hidden="true"></i><span class='name'>本文目录</span>
    
  </header>


    <div class='content'>
        <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#IPSec"><span class="toc-text">IPSec</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%9A%E4%BF%A1%E4%BF%9D%E6%8A%A4%E5%8D%8F%E8%AE%AE"><span class="toc-text">通信保护协议</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#AH"><span class="toc-text">AH</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#ESP"><span class="toc-text">ESP</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AF%86%E9%92%A5%E4%BA%A4%E6%8D%A2%E7%AE%A1%E7%90%86%E5%8D%8F%E8%AE%AEIKE"><span class="toc-text">密钥交换管理协议IKE</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%98%B6%E6%AE%B51"><span class="toc-text">阶段1</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%98%B6%E6%AE%B52"><span class="toc-text">阶段2</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#SSL"><span class="toc-text">SSL</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#SSL%E5%88%86%E5%B1%82%E7%BB%93%E6%9E%84"><span class="toc-text">SSL分层结构</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#SSL%E6%8F%A1%E6%89%8B%E5%8D%8F%E8%AE%AE"><span class="toc-text">SSL握手协议</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#SSL%E8%AE%B0%E5%BD%95%E5%8D%8F%E8%AE%AE"><span class="toc-text">SSL记录协议</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#SSL%E5%8D%8F%E8%AE%AE%E5%AE%89%E5%85%A8%E6%80%A7%E5%88%86%E6%9E%90"><span class="toc-text">SSL协议安全性分析</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#SSL%E8%84%86%E5%BC%B1%E6%80%A7%E5%88%86%E6%9E%90"><span class="toc-text">SSL脆弱性分析</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#SET"><span class="toc-text">SET</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8F%8C%E9%87%8D%E6%95%B0%E5%AD%97%E7%AD%BE%E5%90%8D"><span class="toc-text">双重数字签名</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#SET%E7%94%B5%E5%AD%90%E6%94%AF%E4%BB%98%E6%B5%81%E7%A8%8B"><span class="toc-text">SET电子支付流程</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#SET%E6%A0%B8%E5%BF%83%E6%8A%80%E6%9C%AF"><span class="toc-text">SET核心技术</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#PGP"><span class="toc-text">PGP</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#PGP%E6%95%B0%E5%AD%97%E7%AD%BE%E5%90%8D%E4%B8%8E%E8%AE%A4%E8%AF%81"><span class="toc-text">PGP数字签名与认证</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#PGP%E4%BF%9D%E5%AF%86%E6%80%A7"><span class="toc-text">PGP保密性</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#PGP%E4%BF%9D%E5%AF%86%E5%92%8C%E8%AE%A4%E8%AF%81%E7%BB%93%E5%90%88"><span class="toc-text">PGP保密和认证结合</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#PGP%E5%8E%8B%E7%BC%A9"><span class="toc-text">PGP压缩</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#PGP%E5%AF%86%E9%92%A5%E7%8E%AF"><span class="toc-text">PGP密钥环</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#PGP%E4%BF%A1%E4%BB%BB%E7%BD%91"><span class="toc-text">PGP信任网</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Kerberos"><span class="toc-text">Kerberos</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5"><span class="toc-text">基本概念</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Kerberos%E5%B7%A5%E4%BD%9C%E6%B5%81%E7%A8%8B"><span class="toc-text">Kerberos工作流程</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E8%AE%A4%E8%AF%81%E6%9C%8D%E5%8A%A1%E4%BA%A4%E6%8D%A2%EF%BC%9A%E8%8E%B7%E5%BE%97%E7%A5%A8%E6%8D%AE%E8%AE%B8%E5%8F%AF%E7%A5%A8%E6%8D%AE-ticket-granting-ticket"><span class="toc-text">1. 认证服务交换：获得票据许可票据(ticket granting ticket)</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E7%A5%A8%E6%8D%AE%E8%AE%B8%E5%8F%AF%E6%9C%8D%E5%8A%A1%E4%BA%A4%E6%8D%A2%EF%BC%9A%E8%8E%B7%E5%BE%97%E6%9C%8D%E5%8A%A1%E8%AE%B8%E5%8F%AF%E7%A5%A8%E6%8D%AE-service-granting-ticket"><span class="toc-text">2. 票据许可服务交换：获得服务许可票据(service granting ticket)</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E5%AE%A2%E6%88%B7-%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%AE%A4%E8%AF%81%E4%BA%A4%E6%8D%A2%EF%BC%9A%E8%8E%B7%E5%BE%97%E6%9C%8D%E5%8A%A1image-20201101145321623"><span class="toc-text">3. 客户&#x2F;服务器认证交换：获得服务</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Kerberos%E8%B7%A8%E5%9F%9F%E8%AE%A4%E8%AF%81"><span class="toc-text">Kerberos跨域认证</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Kerberos%E4%BC%98%E7%BC%BA%E7%82%B9"><span class="toc-text">Kerberos优缺点</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BC%98%E7%82%B9"><span class="toc-text">优点</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E7%BC%BA%E7%82%B9"><span class="toc-text">缺点</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#BAN"><span class="toc-text">BAN</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%89%80%E7%94%A8%E7%AC%A6%E5%8F%B7"><span class="toc-text">所用符号</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8E%A8%E7%90%86%E8%A7%84%E5%88%99"><span class="toc-text">推理规则</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%B6%88%E6%81%AF%E6%84%8F%E4%B9%89%E8%A7%84%E5%88%99"><span class="toc-text">消息意义规则</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%9A%8F%E6%9C%BA%E6%95%B0%E9%AA%8C%E8%AF%81%E8%A7%84%E5%88%99"><span class="toc-text">随机数验证规则</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BB%B2%E8%A3%81%E8%A7%84%E5%88%99"><span class="toc-text">仲裁规则</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BF%A1%E4%BB%B0%E8%A7%84%E5%88%99"><span class="toc-text">信仰规则</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%8E%A5%E6%94%B6%E8%A7%84%E5%88%99"><span class="toc-text">接收规则</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%96%B0%E9%B2%9C%E8%A7%84%E5%88%99"><span class="toc-text">新鲜规则</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BC%A0%E9%80%92%E8%A7%84%E5%88%99"><span class="toc-text">传递规则</span></a></li></ol></li></ol></li></ol>
    </div>
  </section>


  


</aside>



        
        
          <!--此文件用来存放一些不方便取值的变量-->
<!--思路大概是将值藏到重加载的区域内-->

<script>
  window.pdata={}
  pdata.ispage=true;
  pdata.postTitle="Internet安全协议与分析Notes";
  pdata.commentPath="";
  pdata.commentPlaceholder="";

  var l_header=document.getElementById("l_header");
  
  l_header.classList.add("show");
  
</script>

        
      </div>
      
  
  <footer class="footer clearfix">
    <br><br>
    
      
        <div class='copyright'>
        <p><a target="_blank" rel="noopener" href="https://github.com/Schenk75/Schenk75.github.io">Copyright © 2020-2022 Schenk</a></p>

        </div>
      
    
  </footer>


      <a id="s-top" class="fas fa-arrow-up fa-fw" href='javascript:void(0)'></a>
    </div>
  </div>
  <div>
    <script>
window.volantis={};
window.volantis.loadcss=document.getElementById("loadcss");
/********************脚本懒加载函数********************************/
function loadScript(src, cb) {
var HEAD = document.getElementsByTagName('head')[0] || document.documentElement;
var script = document.createElement('script');
script.setAttribute('type','text/javascript');
if (cb) script.onload = cb;
script.setAttribute('src', src);
HEAD.appendChild(script);
}
//https://github.com/filamentgroup/loadCSS
var loadCSS = function( href, before, media, attributes ){
	var doc = window.document;
	var ss = doc.createElement( "link" );
	var ref;
	if( before ){
		ref = before;
	}
	else {
		var refs = ( doc.body || doc.getElementsByTagName( "head" )[ 0 ] ).childNodes;
		ref = refs[ refs.length - 1];
	}
	var sheets = doc.styleSheets;
	if( attributes ){
		for( var attributeName in attributes ){
			if( attributes.hasOwnProperty( attributeName ) ){
				ss.setAttribute( attributeName, attributes[attributeName] );
			}
		}
	}
	ss.rel = "stylesheet";
	ss.href = href;
	ss.media = "only x";
	function ready( cb ){
		if( doc.body ){
			return cb();
		}
		setTimeout(function(){
			ready( cb );
		});
	}
	ready( function(){
		ref.parentNode.insertBefore( ss, ( before ? ref : ref.nextSibling ) );
	});
	var onloadcssdefined = function( cb ){
		var resolvedHref = ss.href;
		var i = sheets.length;
		while( i-- ){
			if( sheets[ i ].href === resolvedHref ){
				return cb();
			}
		}
		setTimeout(function() {
			onloadcssdefined( cb );
		});
	};
	function loadCB(){
		if( ss.addEventListener ){
			ss.removeEventListener( "load", loadCB );
		}
		ss.media = media || "all";
	}
	if( ss.addEventListener ){
		ss.addEventListener( "load", loadCB);
	}
	ss.onloadcssdefined = onloadcssdefined;
	onloadcssdefined( loadCB );
	return ss;
};
</script>
<script>
  
  loadCSS("https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.14/css/all.min.css", window.volantis.loadcss);
  
  
  
  
</script>
<!-- required -->

<script src="https://cdn.jsdelivr.net/npm/jquery@3.5/dist/jquery.min.js"></script>

<script>
  function pjax_fancybox() {
    $(".md .gallery").find("img").each(function () { //渲染 fancybox
      var element = document.createElement("a"); // a 标签
      $(element).attr("class", "fancybox");
      $(element).attr("pjax-fancybox", "");  // 过滤 pjax
      $(element).attr("href", $(this).attr("src"));
      if ($(this).attr("data-original")) {
        $(element).attr("href", $(this).attr("data-original"));
      }
      $(element).attr("data-fancybox", "images");
      var caption = "";   // 描述信息
      if ($(this).attr('alt')) {  // 判断当前页面是否存在描述信息
        $(element).attr('data-caption', $(this).attr('alt'));
        caption = $(this).attr('alt');
      }
      var div = document.createElement("div");
      $(div).addClass("fancybox");
      $(this).wrap(div); // 最外层套 div ，其实主要作用还是 class 样式
      var span = document.createElement("span");
      $(span).addClass("image-caption");
      $(span).text(caption); // 加描述
      $(this).after(span);  // 再套一层描述
      $(this).wrap(element);  // 最后套 a 标签
    })
    $(".md .gallery").find("img").fancybox({
      selector: '[data-fancybox="images"]',
      hash: false,
      loop: false,
      closeClick: true,
      helpers: {
        overlay: {closeClick: true}
      },
      buttons: [
        "zoom",
        "close"
      ]
    });
  };
  function SCload_fancybox() {
    if ($(".md .gallery").find("img").length == 0) return;
    loadCSS("https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css", document.getElementById("loadcss"));
    setTimeout(function() {
      loadScript('https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js', pjax_fancybox)
    }, 1);
  };
  $(function () {
    SCload_fancybox();
  });
</script>


<!-- internal -->







  <script defer src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.1.0/dist/lazyload.min.js"></script>
<script>
  // https://www.npmjs.com/package/vanilla-lazyload
  // Set the options globally
  // to make LazyLoad self-initialize
  window.lazyLoadOptions = {
    elements_selector: ".lazyload",
    threshold: 0
  };
  // Listen to the initialization event
  // and get the instance of LazyLoad
  window.addEventListener(
    "LazyLoad::Initialized",
    function (event) {
      window.lazyLoadInstance = event.detail.instance;
    },
    false
  );
  document.addEventListener('DOMContentLoaded', function () {
    lazyLoadInstance.update();
  });
  document.addEventListener('pjax:complete', function () {
    lazyLoadInstance.update();
  });
</script>




  
  
    <script>
      window.FPConfig = {
        delay: 0,
        ignoreKeywords: [],
        maxRPS: 5,
        hoverDelay: 25
      };
    </script>
    <script defer src="https://cdn.jsdelivr.net/gh/gijo-varghese/flying-pages@2.1.2/flying-pages.min.js"></script>
  




  <script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
    var clipboard = new ClipboardJS('.btn-copy', {
        target: function (trigger) {
            return trigger.nextElementSibling
        }
    });
    function wait(callback, seconds) {
        var timelag = null;
        timelag = window.setTimeout(callback, seconds)
    }
    function pjax_initCopyCode() {
		if($(".highlight .code pre").length+$(".article pre code").length==0)return;
        var copyHtml = '';
        copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
        copyHtml += '<i class="fas fa-copy"></i><span>COPY</span>';
        copyHtml += '</button>';
        $(".highlight .code pre").before(copyHtml);
        $(".article pre code").before(copyHtml);
        clipboard.off('success').on('success', function (e) {
            let $btn = $(e.trigger);
            $btn.addClass('copied');
            let $icon = $($btn.find('i'));
            $icon.removeClass('fa-copy');
            $icon.addClass('fa-check-circle');
            let $span = $($btn.find('span'));
            $span[0].innerText = 'COPIED';
            wait(function () {
                $icon.removeClass('fa-check-circle');
                $icon.addClass('fa-copy');
                $span[0].innerText = 'COPY'
            }, 2000)
        });
        clipboard.off('error').on('error', function (e) {
            e.clearSelection();
            let $btn = $(e.trigger);
            $btn.addClass('copy-failed');
            let $icon = $($btn.find('i'));
            $icon.removeClass('fa-copy');
            $icon.addClass('fa-times-circle');
            let $span = $($btn.find('span'));
            $span[0].innerText = 'COPY FAILED';
            wait(function () {
                $icon.removeClass('fa-times-circle');
                $icon.addClass('fa-copy');
                $span[0].innerText = 'COPY'
            }, 2000)
        })
    }
    $(function () {
        pjax_initCopyCode()
    });
</script>










  <script defer src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/tools/busuanzi.pure.mini.js" data-pjax></script>


  
<script src="https://cdn.jsdelivr.net/npm/hexo-theme-volantis@4.1.5/source/js/app.min.js"></script>




  
  
<script src="https://cdn.jsdelivr.net/npm/hexo-theme-volantis@4.1.5/source/js/search.min.js"></script>

  


<!-- optional -->

  <script>
const SearchServiceimagePath="https://cdn.jsdelivr.net/gh/volantis-x/cdn-volantis@master/img/";
const ROOT =  ("/" || "/").endsWith('/') ? ("/" || "/") : ("//" || "/" );
function listenSearch(){
  
    customSearch = new HexoSearch({
      imagePath: SearchServiceimagePath
    });
  
}
document.addEventListener("DOMContentLoaded", listenSearch);

</script>











  <script defer>

  const LCCounter = {
    app_id: 'u9j57bwJod4EDmXWdxrwuqQT-MdYXbMMI',
    app_key: 'jfHtEKVE24j0IVCGHbvuFClp',
    custom_api_server: '',

    // 查询存储的记录
    getRecord(Counter, url, title) {
      return new Promise(function (resolve, reject) {
        Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify({url})))
          .then(resp => resp.json())
          .then(({results, code, error}) => {
            if (code === 401) {
              throw error;
            }
            if (results && results.length > 0) {
              var record = results[0];
              resolve(record);
            } else {
              Counter('post', '/classes/Counter', {url, title: title, times: 0})
                .then(resp => resp.json())
                .then((record, error) => {
                  if (error) {
                    throw error;
                  }
                  resolve(record);
                }).catch(error => {
                console.error('Failed to create', error);
                reject(error);
              });
            }
          }).catch((error) => {
          console.error('LeanCloud Counter Error:', error);
          reject(error);
        });
      })
    },

    // 发起自增请求
    increment(Counter, incrArr) {
      return new Promise(function (resolve, reject) {
        Counter('post', '/batch', {
          "requests": incrArr
        }).then((res) => {
          res = res.json();
          if (res.error) {
            throw res.error;
          }
          resolve(res);
        }).catch((error) => {
          console.error('Failed to save visitor count', error);
          reject(error);
        });
      });
    },

    // 构建自增请求体
    buildIncrement(objectId) {
      return {
        "method": "PUT",
        "path": `/1.1/classes/Counter/${ objectId }`,
        "body": {
          "times": {
            '__op': 'Increment',
            'amount': 1
          }
        }
      }
    },

    // 校验是否为有效的 UV
    validUV() {
      var key = 'LeanCloudUVTimestamp';
      var flag = localStorage.getItem(key);
      if (flag) {
        // 距离标记小于 24 小时则不计为 UV
        if (new Date().getTime() - parseInt(flag) <= 86400000) {
          return false;
        }
      }
      localStorage.setItem(key, new Date().getTime().toString());
      return true;
    },

    addCount(Counter) {
      var enableIncr = '' === 'true' && window.location.hostname !== 'localhost';
      enableIncr = true;
      var getterArr = [];
      var incrArr = [];
      // 请求 PV 并自增
      var pvCtn = document.querySelector('#lc-sv');
      if (pvCtn || enableIncr) {
        var pvGetter = this.getRecord(Counter, 'http://example.com' + '/#lc-sv', 'Visits').then((record) => {
          incrArr.push(this.buildIncrement(record.objectId))
          var eles = document.querySelectorAll('#lc-sv #number');
          if (eles.length > 0) {
            eles.forEach((el,index,array)=>{
              el.innerText = record.times + 1;
              if (pvCtn) {
                pvCtn.style.display = 'inline';
              }
            })
          }
        });
        getterArr.push(pvGetter);
      }

      // 请求 UV 并自增
      var uvCtn = document.querySelector('#lc-uv');
      if (uvCtn || enableIncr) {
        var uvGetter = this.getRecord(Counter, 'http://example.com' + '/#lc-uv', 'Visitors').then((record) => {
          var vuv = this.validUV();
          vuv && incrArr.push(this.buildIncrement(record.objectId))
          var eles = document.querySelectorAll('#lc-uv #number');
          if (eles.length > 0) {
            eles.forEach((el,index,array)=>{
              el.innerText = record.times + (vuv ? 1 : 0);
              if (uvCtn) {
                uvCtn.style.display = 'inline';
              }
            })
          }
        });
        getterArr.push(uvGetter);
      }

      // 请求文章的浏览数，如果是当前页面就自增
      var allPV = document.querySelectorAll('#lc-pv');
      if (allPV.length > 0 || enableIncr) {
        for (i = 0; i < allPV.length; i++) {
          let pv = allPV[i];
          let title = pv.getAttribute('data-title');
          var url = 'http://example.com' + pv.getAttribute('data-path');
          if (url) {
            var viewGetter = this.getRecord(Counter, url, title).then((record) => {
              // 是当前页面就自增
              let curPath = window.location.pathname;
              if (curPath.includes('index.html')) {
                curPath = curPath.substring(0, curPath.lastIndexOf('index.html'));
              }
              if (pv.getAttribute('data-path') == curPath) {
                incrArr.push(this.buildIncrement(record.objectId));
              }
              if (pv) {
                var ele = pv.querySelector('#lc-pv #number');
                if (ele) {
                  if (pv.getAttribute('data-path') == curPath) {
                    ele.innerText = (record.times || 0) + 1;
                  } else {
                    ele.innerText = record.times || 0;
                  }
                  pv.style.display = 'inline';
                }
              }
            });
            getterArr.push(viewGetter);
          }
        }
      }

      // 如果启动计数自增，批量发起自增请求
      if (enableIncr) {
        Promise.all(getterArr).then(() => {
          incrArr.length > 0 && this.increment(Counter, incrArr);
        })
      }

    },


    fetchData(api_server) {
      var Counter = (method, url, data) => {
        return fetch(`${ api_server }/1.1${ url }`, {
          method,
          headers: {
            'X-LC-Id': this.app_id,
            'X-LC-Key': this.app_key,
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };
      this.addCount(Counter);
    },

    refreshCounter() {
      var api_server = this.app_id.slice(-9) !== '-MdYXbMMI' ? this.custom_api_server : `https://${ this.app_id.slice(0, 8).toLowerCase() }.api.lncldglobal.com`;
      if (api_server) {
        this.fetchData(api_server);
      } else {
        fetch('https://app-router.leancloud.cn/2/route?appId=' + this.app_id)
          .then(resp => resp.json())
          .then(({api_server}) => {
            this.fetchData('https://' + api_server);
          });
      }
    }

  };

  LCCounter.refreshCounter();

  document.addEventListener('pjax:complete', function () {
    LCCounter.refreshCounter();
  });
</script>








<script>
function listennSidebarTOC() {
  const navItems = document.querySelectorAll(".toc li");
  if (!navItems.length) return;
  const sections = [...navItems].map((element) => {
    const link = element.querySelector(".toc-link");
    const target = document.getElementById(
      decodeURI(link.getAttribute("href")).replace("#", "")
    );
    link.addEventListener("click", (event) => {
      event.preventDefault();
      window.scrollTo({
		top: target.offsetTop + 100,
		
		behavior: "smooth"
		
	  });
    });
    return target;
  });

  function activateNavByIndex(target) {
    if (target.classList.contains("active-current")) return;

    document.querySelectorAll(".toc .active").forEach((element) => {
      element.classList.remove("active", "active-current");
    });
    target.classList.add("active", "active-current");
    let parent = target.parentNode;
    while (!parent.matches(".toc")) {
      if (parent.matches("li")) parent.classList.add("active");
      parent = parent.parentNode;
    }
  }

  function findIndex(entries) {
    let index = 0;
    let entry = entries[index];
    if (entry.boundingClientRect.top > 0) {
      index = sections.indexOf(entry.target);
      return index === 0 ? 0 : index - 1;
    }
    for (; index < entries.length; index++) {
      if (entries[index].boundingClientRect.top <= 0) {
        entry = entries[index];
      } else {
        return sections.indexOf(entry.target);
      }
    }
    return sections.indexOf(entry.target);
  }

  function createIntersectionObserver(marginTop) {
    marginTop = Math.floor(marginTop + 10000);
    let intersectionObserver = new IntersectionObserver(
      (entries, observe) => {
        let scrollHeight = document.documentElement.scrollHeight + 100;
        if (scrollHeight > marginTop) {
          observe.disconnect();
          createIntersectionObserver(scrollHeight);
          return;
        }
        let index = findIndex(entries);
        activateNavByIndex(navItems[index]);
      },
      {
        rootMargin: marginTop + "px 0px -100% 0px",
        threshold: 0,
      }
    );
    sections.forEach((element) => {
      element && intersectionObserver.observe(element);
    });
  }
  createIntersectionObserver(document.documentElement.scrollHeight);
}

document.addEventListener("DOMContentLoaded", listennSidebarTOC);
document.addEventListener("pjax:success", listennSidebarTOC);
</script>

<!-- more -->




    
      


<script src="https://cdn.jsdelivr.net/npm/pjax@0.2.8/pjax.min.js"></script>


<script>
    var pjax;
    document.addEventListener('DOMContentLoaded', function () {
      pjax = new Pjax({
        elements: 'a[href]:not([href^="#"]):not([href="javascript:void(0)"]):not([pjax-fancybox])',
        selectors: [
          "title",
          "#l_cover",
          "#pjax-container",
          "#pjax-header-nav-list"
        ],
        cacheBust: false,   // url 地址追加时间戳，用以避免浏览器缓存
        timeout: 5000
      });
    });

    document.addEventListener('pjax:send', function (e) {
      //window.stop(); // 相当于点击了浏览器的停止按钮

      try {
        var currentUrl = window.location.pathname;
        var targetUrl = e.triggerElement.href;
        var banUrl = [""];
        if (banUrl[0] != "") {
          banUrl.forEach(item => {
            if(currentUrl.indexOf(item) != -1 || targetUrl.indexOf(item) != -1) {
              window.location.href = targetUrl;
            }
          });
        }
      } catch (error) {}

      window.subData = null; // 移除标题（用于一二级导航栏切换处）
      if (typeof $.fancybox != "undefined") {
        $.fancybox.close();    // 关闭弹窗
      }
      volantis.$switcher.removeClass('active'); // 关闭移动端激活的搜索框
      volantis.$header.removeClass('z_search-open'); // 关闭移动端激活的搜索框
      volantis.$wrapper.removeClass('sub'); // 跳转页面时关闭二级导航

      // 解绑事件 避免重复监听
      volantis.$topBtn.unbind('click');
      $('.menu a').unbind('click');
      $(window).unbind('resize');
      $(window).unbind('scroll');
      $(document).unbind('scroll');
      $(document).unbind('click');
      $('body').unbind('click');
	  
    });

    document.addEventListener('pjax:complete', function () {
      // 关于百度统计对 SPA 页面的处理：
      // 方案一：百度统计>管理>单页应用设置中，打开开启按钮即可对SPA进行统计。 https://tongji.baidu.com/web/help/article?id=324
      // 方案二：取消注释下列代码。 https://tongji.baidu.com/web/help/article?id=235
      // 

      // 关于谷歌统计对 SPA 页面的处理：
      // 当应用以动态方式加载内容并更新地址栏中的网址时，也应该更新通过 gtag.js 存储的网页网址。
      // https://developers.google.cn/analytics/devguides/collection/gtagjs/single-page-applications?hl=zh-cn
      

      $('.nav-main').find('.list-v').not('.menu-phone').removeAttr("style",""); // 移除小尾巴的移除
      $('.menu-phone.list-v').removeAttr("style",""); // 移除小尾巴的移除
      $('script[data-pjax], .pjax-reload script').each(function () {
        $(this).parent().append($(this).remove());
      });
      try{
          if (typeof $.fancybox == "undefined") {
            SCload_fancybox();
          } else {
            pjax_fancybox();
          }
        
        
        
        
        
          pjax_initCopyCode();
        
        
        
        
        
      } catch (e) {
        console.log(e);
      }
	  
    });

    document.addEventListener('pjax:error', function (e) {
	  
      window.location.href = e.triggerElement.href;
    });
</script>

    
  </div>
</body>
</html>
